package com.tanhua.server.controller;


import com.tanhua.server.service.UserInfoService;
import com.tanhua.server.service.Userservice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
@Slf4j
public class LoginController {



    @Autowired
    private Userservice userservice;

    @Autowired
    private UserInfoService userInfoService;

    /**
     *      发送验证码
     * @param param  前端传回来的手机号
     * @return
     */
    @PostMapping("/login")
    public ResponseEntity login(@RequestBody Map<String,String> param){
        userservice.sendvalidate(param);
        return ResponseEntity.ok("验证码发送成功");
    }

    /**
     *      登录验证码校验
     * @param param
     * @return
     */
    @PostMapping("/loginVerification")
    public ResponseEntity loginVerification(@RequestBody Map<String,String> param){
        Map<String, Object> loginMap = userservice.login(param);
        return ResponseEntity.ok(loginMap);
    }


}
